package org.eclipse.swt.snippets;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Message {

    public static final SimpleDateFormat format    = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,S");

    private long                         id;
    private Date                         date;
    private Level                        level;
    private String                       thread;
    private String                       clazz;
    private String                       message;
    private StringBuffer                 exception = new StringBuffer();

    public Message(long i) {
        id = i;
    }

    @Override
    public String toString() {
        if (exception.length() > 0)
            return String.format("%-23s %-5s {%s}[%s] %s\n%s", format.format(date), level, thread, clazz, message,
                    exception);
        else
            return String.format("%-23s %-5s {%s}[%s] %s", format.format(date), level, thread, clazz, message);
    }

    /**
     * @return the id
     */
    public long getId() {
        return id;
    }

    /**
     * @param id
     *            the id to set
     */
    public void setId(long id) {
        this.id = id;
    }

    /**
     * @return the date
     */
    public Date getDate() {
        return date;
    }

    /**
     * @param date
     *            the date to set
     */
    public void setDate(Date date) {
        this.date = date;
    }

    /**
     * @return the level
     */
    public Level getLevel() {
        return level;
    }

    /**
     * @param level
     *            the level to set
     */
    public void setLevel(Level level) {
        this.level = level;
    }

    /**
     * @return the thread
     */
    public String getThread() {
        return thread;
    }

    /**
     * @param thread
     *            the thread to set
     */
    public void setThread(String thread) {
        this.thread = thread;
    }

    /**
     * @return the clazz
     */
    public String getClazz() {
        return clazz;
    }

    /**
     * @param clazz
     *            the clazz to set
     */
    public void setClazz(String clazz) {
        this.clazz = clazz;
    }

    /**
     * @return the message
     */
    public String getMessage() {
        return message;
    }

    /**
     * @param message
     *            the message to set
     */
    public void setMessage(String message) {
        this.message = message;
    }

    /**
     * @return the exception
     */
    public StringBuffer getException() {
        return exception;
    }

    /**
     * @param exception
     *            the exception to set
     */
    public void setException(StringBuffer exception) {
        this.exception = exception;
    }
}